import { ApiProperty } from "@nestjs/swagger";

export class ResOp<T = any> {
  @ApiProperty({ type: "object" })
  data?: T;

  @ApiProperty({ type: "number", default: 200 })
  code: number;

  @ApiProperty({ type: "string", default: "success" })
  message: string;

  constructor(code: number, data: T, message = "success") {
    this.code = code;
    this.data = data;
    this.message = message;
  }
}

export class PageDto<T = any> {
  @ApiProperty({ type: "object" })
  list?: T;

  @ApiProperty({ type: "number", default: 0 })
  total: number;

  constructor(total: number, list: T) {
    this.total = total;
    this.list = list;
  }
}
